package com.todoclipse.api;

import java.util.Date;
import java.util.Set;

public class Item extends AbstractItem implements Comparable<Item> {
	private long projectId;
	private boolean inHistory;
	private int priority;
	private boolean faded;
	private String content;
	private boolean checked;
	private Date dueDate; // "Sun Apr 29 23:59:59 2007
	private String dateString; // "29. Apr 2007
	private Set<Item> subtasks;
	
	public Item(long id, long userId, String contetn) {
		super(id,userId);
		content = contetn;
	}

	public boolean isInHistory() {
		return inHistory;
	}

	public void setInHistory(boolean in_history) {
		this.inHistory = in_history;
	}

	public int getPriority() {
		return priority;
	}

	public void setPriority(int priority) {
		this.priority = priority;
	}

	public boolean isFaded() {
		return faded;
	}

	public void setFaded(boolean faded) {
		this.faded = faded;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public long getProjectId() {
		return projectId;
	}

	public void setProjectId(long project_id) {
		this.projectId = project_id;
	}

	public boolean isChecked() {
		return checked;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}

	public Date getDueDate() {
		return dueDate;
	}

	public void setDueDate(Date dueDate) {
		this.dueDate = dueDate;
	}

	public String getDateString() {
		return dateString;
	}

	public void setSubtasks(Set<Item> subtasks) {
		this.subtasks = subtasks;
	}
	
	public Set<Item> getSubtasks() {
		return subtasks;
	}
	
	public int compareTo(Item o) {
		return content.compareTo(o.content);
	}

	@Override
	public boolean equals(Object obj) {
		boolean result = (this == obj);
		if (result == false && obj instanceof Item) {
			Item t = (Item) obj;
			result = this.content.equals(t.content);
		}
		return result;
	}

	@Override
	public int hashCode() {
		return content.hashCode();
	}
}
